package com.mercycrazy.springframework.beans.factory.config;

import com.mercycrazy.springframework.beans.BeansException;
import com.mercycrazy.springframework.beans.PropertyValues;

/**
 * BeanPostProcessor 保证优先于其它 Bean 注册
 * 该类型的 Bean 先注册用来判断业务 Bean 是否需要代理
 *
 * @author <a href="mailto:1443424326@qq.com">mercycrazy</a>
 * @since 2022-11-30
 */
public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {

    /**
     * 在 Bean 对象执行初始化方法之前，执行此方法
     */
    Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException;

    /**
     * 在 Bean 对象实例化完成后，设置属性操作之前执行此方法
     */
    PropertyValues postProcessPropertyValues(PropertyValues pvs, Object bean, String beanName) throws BeansException;

    boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException;

    default Object getEarlyBeanReference(Object bean, String beanName) {
        return bean;
    }
}
